import React from "react";
import { Button, Popconfirm, message } from "antd";
import "antd/dist/antd.css";
import axios from "axios";
import qs from "qs";
export default class DelMeeting extends React.Component {
  constructor(props) {
    super(props);
    this.confirm = this.confirm.bind(this);
  }
  /**点击确认删除 */
  confirm() {
    const { selectedRowKeys, getDataSource } = this.props;
    /**没选中数据时提示 */
    if (selectedRowKeys.length === 0) {
      message.error("没有选中数据");
      return;
    }
    /**删除会议数据 */
    axios
      .post(
        "deletemeetingbyid.rst",
        qs.stringify({
          delArr: selectedRowKeys.join(),
        })
      )
      .then((res) => {
        let response = res.data;
        if (response.resultCode === 0) {
          /**重载表格数据 */
          getDataSource();
          message.success("删除会议成功");
        } else {
          message.error("删除会议失败");
        }
      })
      .catch((error) => {
        message.error("删除会议失败");
      });
  }

  render() {
    return (
      <>
        <Popconfirm
          title="确认删除吗？"
          onConfirm={this.confirm}
          okText="Yes"
          cancelText="No"
        >
          <Button type="primary" danger>
            删除
          </Button>
        </Popconfirm>
      </>
    );
  }
}
